Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main Page #3

Merged
merged 3 commits into from
Mar 9, 2021
Merged

Main Page #3

merged 3 commits into from
Mar 9, 2021

Conversation

lbratkovskaya
Copy link
Owner

Main application page with counties list. Contains routing and i18next internationalization

@lbratkovskaya lbratkovskaya changed the title feat: main page with routing & lang Main Page Mar 7, 2021
// TODO

return (<div title={t(`${countryId}.name`)}>{t(`${countryId}.name`)}</div>);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Файлы компонентов лучше называть по имени компонента вместо index.tsx

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не согласна: именование index.tsx позволяет уменьшить длину строки импорта модуля, так как index - это "специальное" имя, которое ищется внутри папки по умолчанию.

Благодаря index мы можем написать путь './component/App' вместо './components/App/App'

} from 'react-router-dom';


export default function CountryPage(): JSX.Element {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему тип компонента JSX.Element? не лучше в одном стиле, также как и все остальные компоненты, React.FC?

src/types/index.d.ts Outdated Show resolved Hide resolved
src/store/store.ts Outdated Show resolved Hide resolved
src/store/store.ts Show resolved Hide resolved
src/store/store.ts Outdated Show resolved Hide resolved
src/i18next.ts Outdated Show resolved Hide resolved
@AlexeyTeterin
Copy link
Collaborator

Еще у меня как-то некорректно работает роутинг.
При перезагрузке страницы по кнопке в chrome вылезает "Cannot GET /countries" вместо контента.
Если в адресной строке вместо http://localhost:3000/countries вбиваем http://localhost:3000 то страница грузится нормально.

@lbratkovskaya
Copy link
Owner Author

Еще у меня как-то некорректно работает роутинг.
При перезагрузке страницы по кнопке в chrome вылезает "Cannot GET /countries" вместо контента.
Если в адресной строке вместо http://localhost:3000/countries вбиваем http://localhost:3000 то страница грузится нормально.

Это неизбежно. Можно убрать рут countries и делать это корнем

@AlexeyTeterin
Copy link
Collaborator

Еще у меня как-то некорректно работает роутинг.
При перезагрузке страницы по кнопке в chrome вылезает "Cannot GET /countries" вместо контента.
Если в адресной строке вместо http://localhost:3000/countries вбиваем http://localhost:3000 то страница грузится нормально.

Это неизбежно. Можно убрать рут countries и делать это корнем

Тогда я за то чтобы убрать.

@@ -1,9 +1,56 @@
export interface IAppState {
lang: 'EN' | 'RU' | 'DE'
lang: 'EN' | 'RU' | 'DE',
countries: Country[],
}

const initialState: IAppState = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это initial state не всего App, а только для Main page, его лучше вынести в отдельный файл, например, mainPageReduser, и импортировать его в rootReduser

name: 'Japan',
pictureURL: 'https://i-fakt.ru/1/tokio.jpg',
},
],
};

const rootReducer = (state: IAppState = initialState, action: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const rootReducer = (state: IAppState = initialState, action: any)
action type должен быть описан соответствующим интерфейсом, например,
interface IRoorReduserAction {
type: string;
lang?: string;
countries?: Array
}

);
const ImagesGrid: React.FC<rootProps> = (props: rootProps) => {
const classes = useStyles();
const { lang, countries } = props;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если lang не используется, может быть его записать спред-оператором ... . + такой записи еще и втом, что не при раширении rootProps, на придется дописывать новые свойства

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants